<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Asset Manager
 *
 * Software to automatically manage how assets are delivered on a website
 *
 * @package		Asset Manager
 * @author		Adam Lewis <adam.lewis@bestservedcold.com>
 * @copyright	Copyright (c) 2006 - 2012, Best Served Cold Media Limited.
 * @license		http://bestservedcold.com/license.html
 * @link		http://bestservedcold.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * Single Query Assets Library
 *
 * The Asset library simply checks the asset database and returns the asset location.  If the asset
 * is not in the database, then it calls the asset library and queues the asset for processing.
 *
 * @package		Asset Manager
 * @subpackage	Assets
 * @category	Libraries
 * @author  	Adam Lewis <adam.lewis@bestservedcold.com>
 * @since		2012-05-22
 */
require_once(APPPATH.'libraries/Asset_manager.php');
class Am_single_query extends Asset_manager {

	/**
	 * $_page_assets
	 *
	 * An array of page assets for processing later
	 *
	 * @access	protcted
	 * @var 	array
	 */
	public $_page_assets	= array();

	/**
	 * Construct
	 *
	 * @access		public
	 * @since		2012-06-09
	 * @return		void
	 */
	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * Do Work
	 *
	 * Replaces assets with unique codes in the output ready for processing later.
	 *
	 * @access	public
	 * @since	2012-06-08
	 * @param	mixed	$param
	 * @param	integer	$group
	 * @return	string	$unique
	 */
	public function get_asset_src($param, $group = FALSE)
	{
		// Set a unique key which we can reference when we alter the output later
		$unique = 'asset_'.mt_rand();

		// If the $param is an integer and $group is false, then the asset is being called directly by it's id
		$this->_page_assets[$unique] = (is_int($param) && ! $group) ? $param : array($param, $group);

		// return the $unique identifier to put as a placeholder in the output
		return $unique;
	}
}